package com.xinfu.newproject.adapter.matter_repair_adapter;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.google.gson.Gson;
import com.xinfu.newproject.R;
import com.xinfu.newproject.bean.matter_repair.RepairRecordBean;
import com.xinfu.newproject.ui.matter_repair.RepairDetailsActivity;
import com.xinfu.newproject.ui.matter_repair.RepairPartsFragment;


/**
 *
 */
public class MatterListAdapter extends BaseQuickAdapter<RepairRecordBean.ResultBean, BaseViewHolder> {

    TextView nameTv, timeTv, priceTv, carId;

    public MatterListAdapter() {
        super(R.layout.item_matter_list, null);
    }

    @Override
    protected void convert(BaseViewHolder helper, RepairRecordBean.ResultBean item) {
        switch (item.getStatus()) {
            case 100:
                helper.setText(R.id.item_matter_list_status_tv, "待受理");
                helper.setTextColor(R.id.item_matter_list_status_tv, mContext.getResources().getColor(R.color.blue_4a));
                break;
            case 200:
                helper.setText(R.id.item_matter_list_status_tv, "待维修");
                helper.setTextColor(R.id.item_matter_list_status_tv, mContext.getResources().getColor(R.color.blue_4a));
                break;
            case 300:
                helper.setText(R.id.item_matter_list_status_tv, "维修中");
                helper.setTextColor(R.id.item_matter_list_status_tv, mContext.getResources().getColor(R.color.blue_4a));
                break;
            case 500:
                helper.setText(R.id.item_matter_list_status_tv, "挂起中");
                helper.setTextColor(R.id.item_matter_list_status_tv, mContext.getResources().getColor(R.color.blue_4a));
                break;
            case 600:
                if (item.getRepairArea() == 1) {
                    helper.setText(R.id.item_matter_list_status_tv, "待评价");
                    helper.setTextColor(R.id.item_matter_list_status_tv, mContext.getResources().getColor(R.color.colorAccent));
                } else if (item.getRepairArea() == 0) {
                    if (item.getIsPay() != null) {
                        if (item.getIsPay() == 0) {
                            if (item.getConfirmPay() == 0) {
                                helper.setText(R.id.item_matter_list_status_tv, "待支付");
                                helper.setTextColor(R.id.item_matter_list_status_tv, mContext.getResources().getColor(R.color.colorAccent));
                            } else {
                                helper.setText(R.id.item_matter_list_status_tv, "待评价");
                                helper.setTextColor(R.id.item_matter_list_status_tv, mContext.getResources().getColor(R.color.colorAccent));
                            }
                        } else if (item.getIsPay() == 1) {
                            helper.setText(R.id.item_matter_list_status_tv, "待评价");
                            helper.setTextColor(R.id.item_matter_list_status_tv, mContext.getResources().getColor(R.color.colorAccent));
                        }
                    }
                }

                break;
            case 800:
                helper.setText(R.id.item_matter_list_status_tv, "已取消");
                helper.setTextColor(R.id.item_matter_list_status_tv, mContext.getResources().getColor(R.color.blue_4a));
                break;
            case 900:
                helper.setText(R.id.item_matter_list_status_tv, "已评价");
                helper.setTextColor(R.id.item_matter_list_status_tv, mContext.getResources().getColor(R.color.blue_4a));
                break;
        }


        helper.setText(R.id.item_matter_list_time_tv, item.getCreateTime());
        helper.setText(R.id.item_matter_list_type_name_tv, item.getRepairPart());

        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Bundle bundle = new Bundle();
                bundle.putString("response", new Gson().toJson(item));
                bundle.getInt("type", 0);
                ((RepairPartsFragment) mContext).startIntentActivity(RepairDetailsActivity.class, bundle);
            }
        });
    }


}
